import os
import time

def run_command(command):
    """运行 shell 命令并打印输出和错误"""
    # 使用 os.system 执行命令
    print(f"Repeat_Timer [INFO] Running command: {command}")
    exit_code = os.system(command)  # os.system 返回命令的退出状态
    if exit_code == 0:
        print(f"Repeat_Timer [INFO] Command succeeded.")
    else:
        print(f"Repeat_Timer [ERROR] Command failed with exit code {exit_code}.")

if __name__ == "__main__":
    # 定义要运行的命令
    command = "python -m src.main -c config/tasks_ping_monitor.yaml --quiet"

    while True:
        run_command(command)
        print("Repeat_Timer [INFO] Waiting for 10 seconds before the next execution...")
        
        # 等待 60 秒
        time.sleep(10)